<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body style="background-color: white;" class="gray-bg">
	<div class="ibox-content">
		<form class="form-horizontal m-t" id="signupForm" method="post" enctype="multipart/form-data">
		   <input type="hidden" class="form-control" name="id"  value="${collectionRecord.id}"/>
		   <input type="hidden" class="form-control" id="talentsId" name="talentsId"  value="${collectionRecord.talentsId}"/>
		   <input type="hidden" class="form-control" id="accountStatus" name="accountStatus"  value="2"/>
			<div class="form-group">
				<label class="col-sm-3 control-label"> 候选人 ：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="candidate" name="candidate"  value="${collectionRecord.candidate}" readonly="readonly"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label"> 收款类别 ：</label>
				<div class="col-sm-8">
					<label class="radio-inline"> 
					   <input value="1" name="type" type="radio"  disabled="disabled"  <c:if test="${collectionRecord.type eq 1 }">checked</c:if>> 预付款
					</label> 
					<label class="radio-inline">
                          <input value="2" name="type" type="radio"  disabled="disabled"  <c:if test="${collectionRecord.type eq 2 }">checked</c:if>> 首款
					</label>
					<label class="radio-inline">
                          <input value="3" name="type" type="radio"  disabled="disabled"  <c:if test="${collectionRecord.type eq 3 }">checked</c:if>> 尾款
					</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label"> 发票状态 ：</label>
				<div class="col-sm-8">
					 <label class="radio-inline"> 
					   <input value="1" name="status" type="radio" disabled="disabled" <c:if test="${collectionRecord.status eq 1 }">checked</c:if>> 已开
					</label> 
					<label class="radio-inline"> 
					   <input value="2" name="status" type="radio" disabled="disabled"  <c:if test="${collectionRecord.status eq 2 }">checked</c:if>> 未开
					</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label"> 发票号码 ：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="invoiceNum" name="invoiceNum"  value="${collectionRecord.invoiceNum}" readonly="readonly"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label"> 应收金额 ：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="amountReceivable" name="amountReceivable"  value="${collectionRecord.amountReceivable}" onblur="isInteger('amountReceivable',this.value)" readonly="readonly"/>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-12" style="border: 1px solid red;">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label"> 到账日期：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="receivedDate" name="receivedDate"  value="${collectionRecord.receivedDate}" onClick="WdatePicker({startDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})" placeholder="请选择日期"  readonly="readonly"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label"> 实收金额：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="moneyReceived" name="moneyReceived"  value="${collectionRecord.moneyReceived}" onblur="isInteger('moneyReceived',this.value)"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label"> 备注 ：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="remark" name="remark"  value="${collectionRecord.remark}"/>
				</div>
			</div>
			<div class="form-group" style="text-align: center;">
				<div class="col-sm-8 col-sm-offset-3">
					<button class="btn btn-primary" type="button" id="sub">提交</button>
				</div>
			</div>
		</form>
	</div>


	<script>
    $(function () {
	  $("#sub").click(function () {
        	//批量验证表单非空
			//调用方式
        	var arr=new Array(
        	  new Array('receivedDate',' 到账日期未填写!'),
        	  new Array('moneyReceived',' 实收金额未填写!')
        	)
        	  for(var i=0;i<arr.length;i++){
	        	  if($("#"+arr[i][0]).val()==''){
	        		  $("#"+arr[i][0]).tips({
	  					side:3,
	  		            msg:arr[i][1],
	  		            bg:'#AE81FF',
	  		            time:1
	  		        });
	        		  $("#"+arr[i][0]).focus();
	  				return;
	  			}
        	  }
            $("#signupForm").ajaxSubmit({
                url: '<%=contextPath%>/collectionRecord/update',
                type: 'post',
                dataType: "json",
                beforeSend: function () {
			        // 禁用按钮防止重复提交
					$("#sub").attr("disabled","disabled");
					swal("信息已经提交，请等待后台处理~！");
			    },
				success : function(data) {
					if (data.code == 200) {
						swal({
							title : data.message,
							type : "success",
							showCancelButton : false,
							confirmButtonText : "确定",
							animation : "slide-from-bottom",
							text: "2秒后自动关闭。", 
	      	    			timer: 2000, 
							closeOnConfirm : true
						}, function() {
							top.Dialog.close();
						});
					} else {
						swal("错误", data.message, "error");
					}  
				},    
				complete: function () {
			        $("#sub").removeAttr("disabled");
			    },
			    error: function (data) {
			    	swal("错误", data.message, "error");
			    }
        });
    });
  });  
</script>
</body>
</html>